import {createRouter, createWebHashHistory} from "vue-router";
import {routerPages} from "./pages";

/*
* import.meta.env.BASE_URL  这个东西是什么意思 参考这个链接
* https://cn.vitejs.dev/guide/env-and-mode.html#env-variables
*
* */
const router = createRouter({
    history: createWebHashHistory(import.meta.env.VITE_SOME_KEY),
    routes: [
        {
            path: "/",
            name: routerPages.home,
            component: () => import("@/views/Root.vue"),
            redirect: {name: routerPages.discover},
            children: [
                {
                    path: routerPages.discover,
                    name: routerPages.discover,
                    component: () => import("@/views/discover/Discovery.vue"),
                    meta: {
                        menu: "discover",
                        keepAlice: true,
                    }
                },
                {
                    path: 'music',
                    name: 'music',
                    component: () => import("@/views/music/Music.vue"),
                    redirect: {name: 'picked'},
                    meta: {
                        menu: 'music'
                    },
                    children: [
                        {
                            path: "picked",
                            name: 'picked',
                            component: () => import("@/views/music/picked/Picked.vue"),
                            meta: {
                                menu: 'music',
                                keepAlive: true
                            }
                        },
                        {
                            path: 'toplist',
                            name: 'toplist',
                            component: () => import("@/views/music/toplist/TopList.vue"),
                            meta: {
                                menu: 'music',
                                keepAlive: true,
                            }
                        },
                        {
                            path: 'artist',
                            name: 'artist',
                            component: () => import('@/views/music/artist/Artist.vue'),
                            meta: {
                                menu: 'music',
                                title: '歌手',
                                keepAlive: true,
                            }
                        },
                        {
                            path: routerPages.category,
                            name: routerPages.category,
                            component: () => import('@/views/music/category/Category.vue'),
                            meta: {
                                menu: 'music',
                                title: '分类歌单',
                                keepAlive: true,
                            }
                        }
                    ]
                },
                {
                    path: 'playlist',
                    name: 'playlist',
                    component: () => import('@/views/playlist/PlayList.vue'),
                },
                {
                    path: 'video',
                    name: 'video',
                    component: () => import('@/views/video/Video.vue'),
                    meta: {
                        menu: 'video',
                        title: '视频',
                        keepAlive: true,
                    }
                },
                {
                    path: routerPages.mvDetail,
                    name: routerPages.mvDetail,
                    component: () => import('@/views/mv/mvDetail.vue'),
                }
            ]
        }
    ]
});

export default router;
